<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="hardcode2013.*" %>

<html>
	<head>
		<link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />
		
		<script type="text/javascript">
			function onChangeLoginStandard() {
				document.getElementById("login_type_google").style.display = "none";
				document.getElementById("login_type_standard").style.display = "inline";
			}
			function onChangeLoginGoogle() {
				document.getElementById("login_type_google").style.display = "inline";
				document.getElementById("login_type_standard").style.display = "none";
			}
			function onChangeCreateStandard() {
				document.getElementById("create_type_google").style.display = "none";
				document.getElementById("create_type_standard").style.display = "inline";
			}
			function onChangeCreateGoogle() {
				document.getElementById("create_type_google").style.display = "inline";
				document.getElementById("create_type_standard").style.display = "none";
			}
			window.onload = function()
            {
				onChangeLoginStandard();
				onChangeCreateStandard();
            };
		</script>
	</head>

	<body>
  
		<%@include file="include_header.jsp" %>
  
		<%
		if (profile == null) {
			String googleEmail = GoogleUtil.getEmail();
			%>
			<fieldset>
				<legend>Demo Info</legend>
				Demo (standard) account usernames: hardcodetest1, hardcodetest2, User1, User2, ..., User 25<br>
				Admin accounts: hardcodetest1, hardcodetest2<br>
				Password same as username (case sensitive)
			</fieldset>
			
			<fieldset>
				<legend>Login</legend>
				<form action="/account" method="post">
					<input type="radio" name="type" value="standard" onchange="onChangeLoginStandard()" checked>Standard<br>
					<input type="radio" name="type" value="google" onchange="onChangeLoginGoogle()">Google<br>
					<div id="login_type_standard">
						Username: <input type="text" name="username"><br>
						Password: <input type="password" name="password"><br>
					</div>
					<div id="login_type_google">
						<% if (googleEmail == null) { %> Google Account: <a href="<%= EncodeUtil.encodeHtml(GoogleUtil.getLoginUrl(request.getRequestURI())) %>">Login</a><br>
						<% } else { %> Google Account: <%= EncodeUtil.encodeHtml(googleEmail) %><br>
						<% } %>
					</div>
					<input type="hidden" name="action" value="login_account">
					<input type="hidden" name="redirect" value="/">
					<input type="hidden" name="redirect_error" value="/login.jsp">
					<input type="submit" value="Login" />
					</form>
			</fieldset>
			
			<fieldset>
				<legend>Register</legend>
				<form action="/account" method="post">
					Account type:<br>
					<input type="radio" name="type" value="standard" onchange="onChangeCreateStandard()" checked>Standard : Normal account with username and password<br>
					<input type="radio" name="type" value="google" onchange="onChangeCreateGoogle()">Google : Account attached to your Google account<br>
					<input type="checkbox" name="admin">Is Administrator<br>
					<div id="create_type_standard">
						Username: <input type="text" name="username"><br>
						Password: <input type="password" name="password"><br>
						Confirm Password: <input type="password" name="confirm_password"><br>
					</div>
					<div id="create_type_google">
						<% if (googleEmail == null) { %>
							Google Account: <a href="<%= EncodeUtil.encodeHtml(GoogleUtil.getLoginUrl(request.getRequestURI())) %>">Login</a><br>
						<% } else { %> Google Account: <%= EncodeUtil.encodeHtml(googleEmail) %><br>
						<% } %>
						Username: <input type="text" name="nickname"><br>
					</div>
					<input type="hidden" name="action" value="create_account">
					<input type="hidden" name="redirect" value="/">
					<input type="hidden" name="redirect_error" value="/login.jsp">
					<input type="submit" value="Create" />
				</form>
			</fieldset>
			<%
		}
		%>
	</body>
</html>